package com.wenhao.netease.internet;

import java.util.*;

public class Main3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while (scanner.hasNext()) {
            list.add(scanner.nextInt());
        }
        int[] paper1 = new int[list.size()];
        paper1[0] = 1;
        for (int i = 1;i < list.size();i++) {
            if (list.get(i) <= list.get(i - 1)) {
                paper1[i] = 1;
            } else {
                paper1[i] = paper1[i - 1] + 1;
            }
        }
        int[] paper2 = new int[list.size()];
        paper2[list.size() - 1] = 1;
        for (int i = list.size() - 2;i > -1;i--) {
            if (list.get(i) <= list.get(i + 1)) {
                paper2[i] = 1;
            } else {
                paper2[i] = paper2[i + 1] + 1;
            }
        }
        int[] paper = new int[list.size()];
        for (int i = 0;i < paper.length;i++) {
            paper[i] = Math.max(paper1[i],paper2[i]);
        }
        System.out.println(Arrays.stream(paper).sum());
    }
}
